//
//  TableView.h
//  itv
//
//  Created by Zhang Yinghui on 9/28/11.
//  Copyright 2011 LavaTech. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "BKLineView.h"

enum  {
	BKTableViewCellStyleDefault,
	BKTableViewCellStyleImage,
};
typedef NSInteger BKTableViewCellStyle;

enum{
    SeparatorLineStyleNone,
	SeparatorLineStyleTop = 1 << 0,
	SeparatorLineStyleBottom = 1 << 1
};
typedef NSInteger SeparatorLineStyle;

@interface BKTableViewCellBackground : UIView
@property (nonatomic, assign) SeparatorLineStyle separatorLineStyle;
@property (nonatomic, retain) UIColor *topLineColor;
@property (nonatomic, retain) UIColor *bottomLineColor;
@property (nonatomic, retain) UIImage *backgroundImage;
- (void)setTopLineColor:(UIColor *)topLineColor bottomLineColor:(UIColor *)bottomLineColor;
@end

@interface BKTableViewSectionView : BKTableViewCellBackground

@property (nonatomic, readonly) UILabel *titleLabel;
@property (nonatomic, readonly) UILabel *rightLabel;
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *rightTitle;
@property (nonatomic, retain) UIView *rightView;
@property (nonatomic, retain) UIImage *leftImage;
@property (nonatomic, retain) UIImage *rightImage;
@property (nonatomic, assign) id object;

- (void)addTarget:(id)target action:(SEL)action;

@end



@class BKTableView;

@protocol BKTableViewDelegate <NSObject>
@optional
- (void)tableView:(id)tableView didLoadedImageAtPath:(NSString *)imagePath forIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(id)tableView cacheImagePath:(NSString *)imagePath forIndexPath:(NSIndexPath *)indexPath;
@end

@interface BKTableView : UITableView <UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, retain) NSOperationQueue *queue;
@property (nonatomic, retain) BKLineView *topLine;
@property (nonatomic, assign) BOOL useCache;
@property (nonatomic, retain) NSMutableDictionary *imgCache;

- (void)addFormRow:(int)fromRow toRow:(int)toRow forSection:(int)section;
- (void)loadImage:(NSString *)imgURL forIndexPath:(NSIndexPath *)indexPath;

- (NSString *)imageCacheForIndexPath:(NSIndexPath *)indexPath;
- (NSString *)imageCacheForUrl:(NSString *)url;
- (void)cacheImage:(NSString *)imgLocalPath forIndexPath:(NSIndexPath *)indexPath;
@end
